package com.muyan.sys.framework.config;

import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Mybatis-Plus配置
 */
@Configuration
public class MybatisPlusConfig {
  @Bean
    public MybatisPlusInterceptor muyabMybatisPlusInterceptor() {
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();

        //启用多租户插件
     //  interceptor.addInnerInterceptor(new TenantLineInnerInterceptor(new MyTenantLineHandlerImpl()));
      //加解密
      //  interceptor.addInnerInterceptor(new EncryptInterceptor());
     //   interceptor.addInnerInterceptor(new ScopeInterceptor(new ScopeLineHandlerImpl()));

        //乐观锁
        //OptimisticLockerInnerInterceptor optimisticLockerInnerInterceptor = new OptimisticLockerInnerInterceptor();
        //interceptor.addInnerInterceptor(optimisticLockerInnerInterceptor);

      interceptor.addInnerInterceptor(new PaginationInnerInterceptor());
      return interceptor;
    }
/*
    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor(TenantLineHandler tenantHandler) {
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        interceptor.addInnerInterceptor(new TenantLineInnerInterceptor(tenantHandler));
        // 如果用了分页插件注意先 add TenantLineInnerInterceptor 再 add PaginationInnerInterceptor
        // 用了分页插件必须设置 MybatisConfiguration#useDeprecatedExecutor = false
        interceptor.addInnerInterceptor(new PaginationInnerInterceptor());
        return interceptor;
    }
*/



}
